// JavaScript Document
function initOrder(){
	$("#subCol .subcontent2 .dd").mouseover(function(){
		$(".ddplus",this.parentNode.parentNode).hide();
		$(".ddplus",this.parentNode).show();
		
		$("dd",this.parentNode.parentNode).removeClass("cur");
		this.parentNode.className="cur";
	});
	
	$("#mainCol table tr.orderrow").each(function(){
		setXiaoji(this);
	});
	
	setHeJi();	
	
	$("#mainCol table tr.orderrow .taoshu").keyup(function(e){
		if(isNum(e.target)){
			taoshuChanage(e.target);
		}
	});
	
	$("#mainCol table tr.orderrow li.up").click(function(e){
		var taoshu=$(".taoshu",$(e.target).parents(".numbox")).get(0);
		taoshu.value=taoshu.value-0+1;
		taoshuChanage(taoshu);
	});
	$("#mainCol table tr.orderrow li.down").click(function(e){
		var taoshu=$(".taoshu",$(e.target).parents(".numbox")).get(0);
		if (taoshu.value-0>1){
			taoshu.value=taoshu.value-1;
			taoshuChanage(taoshu);
		}
	});
}

function setXiaoji(obj){
	var zhekoumubiao=$(".zhekoumubiao",obj).html()-0;
	var zhekoushu=$(".zhekoushu",obj).html()-0;
	var price=$(".price",obj).html()-0;
	var taoshu=$("input.taoshu",obj).val()-0;
	
	var xiaoji=0;
	var zhekou=10;
	if (taoshu>=zhekoumubiao){
		zhekou=zhekoushu;
	}
	xiaoji=taoshu*price*zhekou/10;
	
	var xiaojirow=$(obj).next();
	$(".taoshuxiaoji",xiaojirow).html(taoshu);
	$(".zhekouxiaoji",xiaojirow).html(zhekou);
	$(".jiagexiaoji",xiaojirow).html(changeTwoDecimal_f(xiaoji));
	
	return xiaoji;
}

function taoshuChanage(e){
	var obj = $(e).parents(".orderrow").get(0);
	setXiaoji(obj);
	
	setHeJi()
}

function setHeJi(){
	var heji=0;
	$("#mainCol table .xiaoji .jiagexiaoji").each(function(){
		heji=heji+(this.innerHTML-0);
	});
	$("#mainCol table tfoot .zongjine").html(heji);
}